// 配置生产环境
const webpackMerge = require('webpack-merge')
const common = require('./webpack.common.js')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const path = require('path')
module.exports = webpackMerge.merge(common, {
    mode: 'production',
    devtool:'none',
    optimization:{
        usedExports:true,
         // 尽可能合并每一个模块到一个函数中
        concatenateModules: true,
        minimize:true //开启压缩
    },
    plugins: [
        new CleanWebpackPlugin(),
        new CopyWebpackPlugin(
            {
                patterns: [
                    {
                        from: path.resolve(__dirname, './public'), //定义要拷贝的源目录，必填项
                        to: 'public', //定义要拷贝到的目标目录，非必填，不填写则拷贝到打包的output输出地址中
                        globOptions: {
                            //忽略index.html
                            ignore: ['**/public/index.html'],
                          },
                    }
                ],
                
            }
        ),
    ],
})